package com.example.interceptor;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Enumeration;

public class CommInterceptor implements HandlerInterceptor {
    private static final Logger logger = LoggerFactory.getLogger(CommInterceptor.class);

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object o) throws Exception {
        logger.info("-----------------test-----------");
        Enumeration em = request.getHeaderNames();
        while(em.hasMoreElements()){
            String name = em.nextElement().toString();
            String value = request.getHeader(name);
            logger.info(">>>>>>>>>name={},value={}",name,value);
        }
//        logger.info("-----session_id={}, maxIn={}", request.getSession().getId(),request.getSession().getMaxInactiveInterval());
        return true;
    }
}
